import java.lang.StringBuilder;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class A240 {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input;
		StringBuilder output = new StringBuilder();
		int m = Integer.parseInt(br.readLine()), n;
		int a;    final int b = 17;
		int quotient = 0, sum;
		
		for(int c = 0; c < m; c++) {
			input = br.readLine();
			n = Integer.parseInt(input);
			
			a = 1; sum = 0;
			for(int i = 0; i < n; i++) {
				a = ((a % b) * 10);
				quotient = (a / b);
				sum += quotient;
			}
			output.append(quotient + " " + sum);
			output.append('\n');
		}
		
		System.out.print(output);
	} // end of main
} // end of class A240